<template>
  <div class="consultation">
    <h2>计费管理</h2>
    <div class="consultation-block">
      <el-form ref="form" :model="form" label-width="160px" size="mini">
        <el-form-item label="A型血价格/100ml">
          <el-input v-model="form.aPrice"></el-input>
        </el-form-item>
        <el-form-item label="B型血价格/100ml">
          <el-input v-model="form.bPrice"></el-input>
        </el-form-item>
        <el-form-item label="AB型血价格/100ml">
          <el-input v-model="form.abPrice"></el-input>
        </el-form-item>
        <el-form-item label="O型血价格/100ml">
          <el-input v-model="form.oPrice"></el-input>
        </el-form-item>
      </el-form>
      <div style="text-align: center;">
        <el-button style="margin: 0 auto;" size="mini" type="danger" @click="updateData">编辑</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { getPrice, updatePrice } from "../service.js";
export default {
  name: "home",
  beforeCreate() {
    getPrice().then(res => {
      this.form = res.data.data[0]
    })
  },
  data() {
    return {
      form: {
        aPrice: "",
        abPrice: "",
        bPrice: '',
        checkPrice: '',
        oPrice: '',
      },
    };
  },
  methods: {
    updateData() {
      console.log(this.form)
      updatePrice(this.form.id, this.form).then(res => {
        console.log(res)
        if (res.code === 200) {
          this.$message.success('修改成功')
        }
      })
    },
  },
};
</script>

<style scoped>
h2 {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 20px;
}
.consultation-block {
  width: 90%;
  margin-left: 5%;
}

.pagination {
  text-align: center;
  margin-top: 20px;
}
.el-tag + .el-tag {
  margin-left: 10px;
}
.button-new-tag {
  margin-left: 10px;
  height: 32px;
  line-height: 30px;
  padding-top: 0;
  padding-bottom: 0;
}
.input-new-tag {
  width: 90px;
  margin-left: 10px;
  vertical-align: bottom;
}

.el-icon-circle-close {
  position: absolute;
  top: -5px;
  right: -5px;
  cursor: pointer;
  color: red;
}
</style>
